
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="Content-Language" content="zh-cn">
    <meta name="apple-mobile-web-app-capable" content="no"/>
    <meta name="apple-touch-fullscreen" content="yes"/>
    <meta name="format-detection" content="telephone=no,email=no"/>
    <meta name="apple-mobile-web-app-status-bar-style" content="white">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
    <meta http-equiv="Expires" content="0">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Cache-control" content="no-cache">
    <meta http-equiv="Cache" content="no-cache">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <title>newbee-mall 支付</title>
    <link th:href="@{/mall/styles/pay.css}" rel="stylesheet" media="screen">
    <script type="text/javascript" src="https://cdn.staticfile.org/jquery/1.11.1/jquery.min.js"></script>
</head>

<body>
<div class="body">
    <h1 class="mod-title">
        <span class="ico_log icon-ali-pay"></span>
    </h1>

    <div class="mod-ct">
        <div class="order">
        </div>
        <div class="amount" id="money">￥
            <th:block th:text="${priceTotal+'0'}"></th:block>
        </div>
        <div class="qrcode-img-wrapper" data-role="qrPayImgWrapper">
            <div data-role="qrPayImg" class="qrcode-img-area">
                <div class="ui-loading qrcode-loading" data-role="qrPayImgLoading"></div>
                <div style="position: relative;display: inline-block;">
                    <img width="300" height="300"
                         th:src="@{/mall/image/pay/alipay_qrcode.jpg}"
                         title="请尽快支付~"
                         style="display: block;">
                </div>
            </div>
        </div>

        <div class="time-item" style="padding-top: 10px">
            <div class="time-item" id="msg">
                <h1>支付完成后，将跳转至订单详情</h1>
            </div>
            <div class="time-item">
                <h1>订单:
                    <th:block th:text="${order.orderNo}"></th:block>
                </h1>
            </div>
            <input type="hidden" id="orderNoValue" th:value="${order.orderNo}">
        </div>

        <div class="tip">
            <div class="ico-scan-ali"></div>
            <div class="tip-text">
                <p id="showtext">打开支付宝 [扫一扫]</p>
            </div>
            <div class="tip-text">
                <a onclick="payOrderSuccess(1)"
                   class="btn btn-small btn-success" title="支付成功">支付成功</a>
            </div>
        </div>

        <div class="tip-text">
        </div>

    </div>
    <div class="foot">
    </div>
</div>
<script th:src="@{/admin/plugins/jquery/jquery.min.js}"></script>
<script th:src="@{/mall/jquery/jquery-3.7.1.min.js}"></script>
<script th:src="@{/admin/dist/js/public.js}"></script>
<script th:src="@{/admin/plugins/sweetalert2/sweetalert2.all.min.js}"></script>
<script th:src="@{/mall/js/pay.js}" type="text/javascript"></script>
<script th:inline="javascript">
    let ctx = /*[[@{/}]]*/"";
    if (ctx.endsWith("/")) {
        ctx = ctx.substring(0, ctx.length - 1);
    }
</script>
<script>
    $(document).ready(function() {
        // 监听所有商品链接点击事件，假设所有商品链接都在 #flash, #recommend 这类容器内
        // 你可以根据实际结构调整选择器
        $("#flash, #recommend, #sub_banner").on("click", "a", function(event) {
            var $link = $(this);
            var href = $link.attr("href");
            var id = $link.data("id");
            var name = $link.data("name");

            // 如果没有data-id，尝试从href中提取数字ID，假设URL是item/detail/123这种格式
            if (!id && href) {
                var match = href.match(/(\d+)/);
                if (match) {
                    id = match[1];
                }
            }

            if (!name) {
                // 如果没有data-name，可以用链接文本或空字符串
                name = $link.find(".name").text() || $link.text() || "";
            }

            var eventData = {
                productId: id || "unknown",
                productName: name || "unknown",
                timestamp: new Date().toISOString()
            };

            // 发送 Ajax 请求
            $.ajax({
                url: '/api/track/click',
                method: 'POST',
                contentType: 'application/json',
                data: JSON.stringify(eventData),
                success: function() {
                    console.log("点击事件已发送：", eventData);
                },
                error: function(err) {
                    console.error("点击事件发送失败：", err);
                }
            });
        });
    });
</script>
</body>
</html>